/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dayouzi.crawler_data.utils;

import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;
import static jdk.internal.util.xml.XMLStreamWriter.DEFAULT_ENCODING;

/**
 * 此工具类用于读取properties文件中的属性配置
 *
 */
public class PropertiesUtil {

    public static String getProperties(String key) {
        try {
            // 获取文件流
            InputStream inputStream = (InputStream) PropertiesUtil.class.getResourceAsStream("/constant.properties");

            Properties prop = new Properties();

            prop.load(new InputStreamReader(inputStream, DEFAULT_ENCODING)); //加载格式化后的流

            return prop.getProperty(key);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return "";
    }

}
